﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InstantSpine.Core.ParaSpine
{
    sealed class APDLScript
    {
        private StringBuilder ScriptBuffer { get; set; }

        public string ScriptSource {
            get { return ScriptBuffer.ToString(); }
        }

        public APDLScript() {
            ScriptBuffer = new StringBuilder();
        }

        public void Comment(string commentLine) {
            ScriptBuffer.AppendLine(string.Format("!{0}", commentLine));
        }

        public void Assign<T>(string pname, T pvalue) {
            ScriptBuffer.AppendLine(string.Format("{0} = {1}", pname, pvalue));
        }

        public void DefineArray(string pname, int rows) {
            ScriptBuffer.AppendLine(string.Format("*dim, {0}, array, {1}", pname, rows));
        }

        public void DefineArray2D(string pname, int rows, int cols) {
            ScriptBuffer.AppendLine(string.Format("*dim, {0}, array, {1}, {2}", pname, rows, cols));
        }

        public void EmptyLine() {
            ScriptBuffer.AppendLine();
        }
    }    
}
